
package com.bluelinelabs.conductor.demo.controllers;

import ohos.agp.components.Component;
import ohos.agp.components.StackLayout;

import com.bluelinelabs.conductor.conductor.Router;
import com.bluelinelabs.conductor.conductor.RouterTransaction;
import com.bluelinelabs.conductor.demo.ResourceTable;
import com.bluelinelabs.conductor.demo.controllers.base.BaseController;

import java.util.ArrayList;
import java.util.List;


/**
 * lipeiquan
 *
 * @since 2021-05-06
 */
public class MultipleChildRouterController extends BaseController {
    public MultipleChildRouterController() {
        super(ResourceTable.Layout_controller_multiple_child_routers);
    }

    @Override
    public void onViewCreated(Component component) {
        title = "Child Router Demo";

        StackLayout stackLayout0 = (StackLayout) component.findComponentById(ResourceTable.Id_container_0);
        StackLayout stackLayout1 = (StackLayout) component.findComponentById(ResourceTable.Id_container_1);
        StackLayout stackLayout2 = (StackLayout) component.findComponentById(ResourceTable.Id_container_2);

        Router childRouter0 = getChildRouter(stackLayout0).setPopsLastView(false);
        if (!childRouter0.hasRootController()) {
            childRouter0.setRoot(RouterTransaction.with(new NavigationDemoController(0, NavigationDemoController.DisplayUpMode.HIDE, false)));
        }

        Router childRouter1 = getChildRouter(stackLayout1).setPopsLastView(false);
        if (!childRouter1.hasRootController()) {
            childRouter1.setRoot(RouterTransaction.with(new NavigationDemoController(0, NavigationDemoController.DisplayUpMode.HIDE, false)));
        }

        Router childRouter2 = getChildRouter(stackLayout2).setPopsLastView(false);
        if (!childRouter2.hasRootController()) {
            childRouter2.setRoot(RouterTransaction.with(new NavigationDemoController(0, NavigationDemoController.DisplayUpMode.HIDE, false)));
        }

    }
}
